package com.qf.mybatisplus.controller;

import com.qf.mybatisplus.bean.entity.Student;
import com.qf.mybatisplus.resultBean.JsonResult;
import com.qf.mybatisplus.service.StudentService;
import com.qf.mybatisplus.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 12136
 * @version 1.0
 * @description: TODO
 * @date 2022/3/9 14:41
 */
@RestController
@RequestMapping("/testPermission")
public class PermissonController {

    @Autowired
    private UserService userService;

    @Autowired
    private StudentService studentService;

    /**
     * @Description  验证此用户是否有此权限
     * @param
     * @Author ZDD
     * @return {com.qf.mybatisplus.resultBean.JsonResult}
     * @Date  2022/3/9 14:37
     **/
//    @RequiresPermissions(value={"user:selectOne"})
    @RequestMapping("/test1")
    public JsonResult test1(){
        Student student = studentService.getOne("小王");
        System.err.println(student);
        return JsonResult.resultOk(student);
    }

    /**
     * @Description  验证此用户是否为此角色
     * @param
     * @Author ZDD
     * @return {com.qf.mybatisplus.resultBean.JsonResult}
     * @Date  2022/3/9 14:37
     **/
//    @RequiresRoles(value = {"admin"})
    @RequestMapping("/test2")
    public JsonResult test2(){


        System.err.println("我是admin");
        return JsonResult.resultOk("我是admin");
    }

//    @RequiresRoles(value = {"超级管理员"})
    @RequestMapping("/test3")
    public JsonResult test3(){
        System.err.println("我是admin");
        return JsonResult.resultOk("");
    }
}
